.compress-public: &compress-public
  - find public -type f -regex '.*\.\(htm\|html\|txt\|text\|js\|json\|css\|svg\|xml\)$' -exec gzip -f -k {} \;
  - find public -type f -regex '.*\.\(htm\|html\|txt\|text\|js\|json\|css\|svg\|xml\)$' -exec brotli -f -k {} \;

pages:
  extends:
    - .default-retry
    - .pages:rules
  stage: pages
  environment: pages
  resource_group: pages
  needs:
    - "rspec:coverage"
    - "coverage-frontend"
    - "compile-production-assets"
    - "compile-storybook"
    - "update-tests-metadata"
    - "generate-frontend-fixtures-mapping"
  before_script:
    - apt-get update && apt-get -y install brotli gzip
  script:
    - mv public/ .public/
    - mkdir public/
    - mkdir -p public/$(dirname "$KNAPSACK_RSPEC_SUITE_REPORT_PATH") public/$(dirname "$FLAKY_RSPEC_SUITE_REPORT_PATH") public/$(dirname "$RSPEC_PACKED_TESTS_MAPPING_PATH") public/$(dirname "$FRONTEND_FIXTURES_MAPPING_PATH")
    - mv coverage/ public/coverage-ruby/ || true
    - mv coverage-frontend/ public/coverage-frontend/ || true
    - mv storybook/public public/storybook || true
    - cp .public/assets/application-*.css public/application.css || true
    - mv $KNAPSACK_RSPEC_SUITE_REPORT_PATH public/$KNAPSACK_RSPEC_SUITE_REPORT_PATH || true
    - mv $FLAKY_RSPEC_SUITE_REPORT_PATH public/$FLAKY_RSPEC_SUITE_REPORT_PATH || true
    - mv $RSPEC_PACKED_TESTS_MAPPING_PATH.gz public/$RSPEC_PACKED_TESTS_MAPPING_PATH.gz || true
    - mv $FRONTEND_FIXTURES_MAPPING_PATH public/$FRONTEND_FIXTURES_MAPPING_PATH || true
    - *compress-public
  artifacts:
    paths:
      - public
    expire_in: 31d
